@extends('layout.page')
@section('title','手工发奖 - 列表')
@section('stylesheet')
    <link href="/css/custom.css" rel="stylesheet">
@endsection

@section('static-page')
        <div class="col-sm-12">
            <div class="ibox">
                <div class="ibox-content form-horizontal">
                    <div class="form-group">
                        <a href="/ceb/handgifts/single" class="btn btn-success">单个奖励</a>
                        <a href="/ceb/handgifts/multi" class="btn btn-success">批量发奖</a>
                        <a href="/ceb/handgifts/group" class="btn btn-success">群体发奖</a>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-1">手机号:</label>
                        <div class="col-sm-4">
                            <input class="form-control" value="{{$phone}}" id="phone">
                        </div>
                        <label class="col-sm-1">面值</label>
                        <div class="col-sm-2">
                            <input class="form-control" value="{{$value}}" id="value">
                        </div>
                        <label class="col-sm-1">状态</label>
                        <div class="col-sm-2">
                            <select class="form-control" id="used">
                                <option value="0" @if($used == 0) selected @endif>全部</option>
                                <option value="1" @if($used == 1) selected @endif>已使用</option>
                                <option value="2" @if($used == 2) selected @endif>未使用</option>
                            </select>
                        </div>
                        <a class="btn btn-success" id="btn-search">搜索</a>
                    </div>
                    <div class="form-group">
                        <table class="table table-bordered text-center">
                            <thead class="text-center">
                            <tr>
                                <th>ID</th>
                                <th>手机号</th>
                                <th>姓名</th>
                                <th>券名称</th>
                                <th>面值</th>
                                <th>生效时间</th>
                                <th>失效时间</th>
                                <th>发送时间</th>
                                <th>起投金额</th>
                                <th>期限</th>
                                <th>状态</th>

                                <th>操作人</th>
                                <th>类型</th>

                            </tr>
                            </thead>
                            <tbody>
                            @foreach($list as $gift)
                                <tr>
                                    <td>{{$gift['id']}}</td>
                                    <td>{{$gift['user']['user_phone']}}</td>
                                    <td>{{$gift['user']['real_name']}}</td>
                                    <td>{{$gift['name']}}</td>
                                    <td>{{$gift['value']}}</td>
                                    <td>{{date('Y-m-d',$gift['start_time'])}}</td>
                                    <td>{{date('Y-m-d',$gift['end_time'])}}</td>
                                    <td>{{date('Y-m-d H:i:s',$gift['create_time'])}}</td>
                                    <td>{{$gift['min_investment']}}</td>
                                    <td>{{$gift['duration']}}</td>
                                    <td>
                                    @if($gift['used'] == 1)
                                        已使用
                                    @elseif($gift['used'] == 2)
                                        未使用
                                    @endif
                                    </td>

                                    <td>{{$gift['operator_name']}}</td>
                                    <td>
                                        @if(isset($gift['type']))
                                            @if($gift['type'] == 1)
                                            手工发奖
                                            @elseif($gift['type'])
                                            活动奖励
                                            @endif
                                        @endif
                                    </td>

                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                        @include('wiget.pager',[
                            'page' => $page,
                            'page_size' => $size,
                            'count' => $count,
                            'show_count' => 10,
                            'path' => '/ceb/handgifts/index?' . http_build_query([
                                'phone' => $phone,
                                'used' => $used,
                                'value' => $value
                            ])
                        ])
                    </div>
                </div>
            </div>
        </div>
@endsection
@section('javascript')
<script>
    $(document).ready(function(){
        $('#btn-search').on('click',function(){
            var phone = $('#phone').val(),
                    value = $('#value').val(),
                    used = $('#used').val();
            var param = {};
            if(phone){
                param.phone = phone;
            }
            if(value){
                param.value = value;
            }
            if(used){
                param.used = used;
            }
            go_page('/ceb/handgifts/index',param);
        });
    });
</script>
@endsection
